<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<script>

function closeWindow() {
    window.close();
}
var saved = false;
function save(){

	var form = document.shipperForm;
    var pa=document.getElementById("errors");
    pa.innerHTML = "";
    if ( typeof document.shipperForm.shipper != "undefined" )
    {
        form.action.value = "saveRelationships";
        if( saved == false)
        {
            saved=true;
            addOptionElementForParentWindow();
            form.submit();
        }
    }
    else
    {
        pa.innerHTML = "Could not save because Shippers does not exist";
    }
}
function reset(){
    document.shipperForm.reset();
}
function addShipper()
{
    var LeftPos=(screen.width)?(screen.width-600)/2:100;
    var TopPos=(screen.height)?(screen.height-250)/2:100;

    newWindow = window.open ('<%=chipTracContext%>/addNewShipper.do?','shippers','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=300,Left= '+LeftPos+',top='+TopPos+',resizable=no');
    if(!newWindow.opener) {newWindow.opener = window}
    newWindow.focus();

}
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}

function addOptionElementForParentWindow()
{
    var shipper = "" ;
    var shipperId = "";
    if ( typeof document.shipperForm.shipper.length == "undefined" )
    {
        shipper = document.shipperForm.shipper.value;
        shipperId = document.shipperForm.shipperId.value
        window.opener.deleteAllOptions();
        window.opener.addOptionToSelect ( "----select----" , "" );
        if (document.shipperForm.shipperId.checked != false)
        {
            window.opener.addOptionToSelect ( shipper , shipperId );
        }
    }
    else
    {
        window.opener.deleteAllOptions();
        window.opener.addOptionToSelect ( "----select----" , "" );
        for( var i=0; i < document.shipperForm.shipper.length; i++ )
        {
            if (document.shipperForm.shipperId[i].checked != false)
            {
                shipper = document.shipperForm.shipper[i].value;
                shipperId = document.shipperForm.shipperId[i].value;
                window.opener.addOptionToSelect ( shipper , shipperId );
            }
        }
    }
}
</script>

<TABLE cellSpacing=0 cellPadding=0 width="40%" border="0">
  <TBODY>
  <TR>
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">
<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->
<center><span class="NArialW">Vendor/Shipper Relationship</span></center>

<html:form name="shipperForm" method="post" action="/vendorShipperRelationship.do" scope="request" type="com.scalar.chiptrack.operations.vendor.forms.ShipperForm" onsubmit="">
<table border="0" width="85%" cellpadding=0 cellspacing=0 align="center">
 <tr>
	<td align=right>
		<a href="javascript:closeWindow();"  onMouseOver="window.status='Click here to close this window';return true"><font class='NArialL'><b>[Close this window]</b></font></a>
	</td>
</tr>
<tr>
	<td class="NArialL">
		<chiptrack:info styleClass="NArialL" />
		<chiptrack:errors styleClass="NArialL" />
        <FONT id="errors" color='FF0000'></FONT>
	</td>
</tr>

<tr class="NArialL"><td>&nbsp;</td></tr>
<tr class="NArialL"><td align="center">Vendor Name:&nbsp;&nbsp;<%= (String)request.getParameter("vendorName")%></td></tr>
<tr class="NArialL"><td>&nbsp;</td></tr>

<tr><td>
<table width="75%" class="NArialL" align="center" border="0" >
<tr bgcolor='#993333' class="NArialL"><td><font color='#FFFFFF'>List of Shippers</font></td></tr>
<logic:iterate id="shipper" name="shippersList">
	<tr>
		<td>
			<input type="checkbox" name="shipperId"
			value="<bean:write name="shipper" property="shipperId" />"
            <bean:write name="shipper" property="flag" />>
			<bean:write name="shipper" property="shipperName" />
            <input type=hidden name='shipper' value='<bean:write name="shipper" property="shipperName" />'/>
		</td>
	</tr>
</logic:iterate>

<tr><td>&nbsp;</td></tr>
</table>
<tr><td>&nbsp;</td></tr>

<tr><td width="20%" colspan="2"><font class="NArialL">Please <a styleClass="leftsection" href="javascript:addShipper()" onmouseover="window.status='Click to Add Shipper';return true" onmouseout="window.status='';return true">
        Click here</a>&nbsp;to Add/Edit Shipper
        </font></td></tr>

<tr><td>&nbsp;</td></tr>
<tr>
<td align="center">

    <a href="javascript:save()" onmouseover="window.status='Click here to Save Shipper Relationships';return true" onmouseout="window.status='';return true" title="Click here to Save Shipper Relationships"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>
    &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:reset()" onmouseover="window.status='Click here to Reset Shipper Relationships';return true" onmouseout="window.status='';return true" title="Click here to Reset Sales Person Relationships"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
</td>
</tr>
<tr class="NArialL"><td>&nbsp;</td></tr>
<tr class="NArialL"><td>&nbsp;</td></tr>
<tr><td align="center"><a href="javascript:closeWindow();" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true" ><font class='NArialL'>Close this window</font></a></td></tr>
</td></tr>
<tr><td>&nbsp;</td></tr>
</table>
<input type="hidden" name="vendorId" value="<%= (String)request.getParameter("vendorId")%>">
<input type="hidden" name="vendorName" value="<%= (String)request.getParameter("vendorName")%>">
<input type="hidden" name="action" value="">
</html:form>
</TR>
</TABLE>
</body>
</html>